package marchsoft.modules.four.admin.controller;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import marchsoft.base.PageVO;
import marchsoft.modules.four.admin.entity.dto.SafeTypeDTO;
import marchsoft.modules.four.admin.service.SafeTypeService;
import marchsoft.modules.four.common.entity.SafeType;
import marchsoft.response.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/api")
@RestController
@RequiredArgsConstructor
public class SafeTypeController {

    private final SafeTypeService service;

    @ApiOperation("分页条件查询")
    @GetMapping("/eSafeType")
    public Result<Object> selectAllRe(PageVO pageVO, SafeTypeDTO safeTypeDTO){
        return Result.success(service.queryAll1(pageVO,safeTypeDTO));
    }

//    @ApiOperation("查询安全分类名称")
//    @GetMapping("/eSafeType/allName")
//    public Result<Object> selectAllSafeTypeName( ){
//        return Result.success(service.selectAllNameSafeType());
//    }

    @ApiOperation("根据id删除安全分类")
    @DeleteMapping("/eSafeType")
    public Result<Object> delete(@RequestBody List<Integer> ids ){
        service.deleteSafeType(ids);
        return Result.success();
    }

    @ApiOperation("新增安全分类")
    @PostMapping("/eSafeType")
    public Result<Object> insert(@RequestBody SafeType safeType){
        service.insertSafeType(safeType);
        return Result.success();
    }

    @ApiOperation("更新安全分类")
    @PutMapping("/eSafeType")
    public Result<Object> update(@RequestBody SafeType safeType){
        service.updateSafeType(safeType);
        return Result.success();
    }
}
